<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="我的发送记录" />
<%@ include file="../inc/Title.jsp"%>
<head>
<link href="/css/Query.css" rel="stylesheet" type="text/css">
<link href="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="/css/BillList.css" />
<script src="/js/QueryList.js"></script>
<script src="/js/popup_ext.js"></script>
<script src="/calendar/dhtmlgoodies_calendar/dhtmlgoodies_calendar.js"></script>
<script language="javascript">
	function checkDateStr(){
		var startDate=document.getElementById("start_date").value;
		if(startDate==null || startDate==''){
			ShowAlert('提示框','请选择开始日期',200,100);
			return false;
		}else{
			var arr=startDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','开始日期格式不正确',200,100);
				return false;
			}
		}
		var endDate=document.getElementById("end_date").value;
		if(endDate==null || endDate==''){
			ShowAlert('提示框','请选择结束日期',200,100);
			return false;
		}else{
			var arr=endDate.split("-");
			if(arr.length==null || arr.length!=3){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return false;
			}else if(isNaN(arr[0]) || isNaN(arr[1]) || isNaN(arr[2])){
				ShowAlert('提示框','结束日期格式不正确',200,100);
				return false;
			}
		}
		return true;
	}
	function createPageParaStr(){
		var str="start_date="+encodeURIComponent(document.getElementById("start_date").value);
		str=str+"&end_date="+encodeURIComponent(document.getElementById("end_date").value);
		
		var status="A";
		if(document.getElementById("status1").checked){
			status="S";
		}else if(document.getElementById("status2").checked){
			status="F";
		}
		str=str+"&status="+status;
		
		str=str+"&rec_name="+encodeURIComponent(document.getElementById("rec_name").value);
		str=str+"&rec_code="+encodeURIComponent(document.getElementById("rec_code").value);
		
		return str;
	}
	
	function createProgramParaStr(){
		var str="start_date="+encodeURIComponent(document.getElementById("hid_start_date").value);
		str=str+"&end_date="+encodeURIComponent(document.getElementById("hid_end_date").value);
		str=str+"&status=${status}";
		str=str+"&rec_name="+encodeURIComponent(document.getElementById("hid_rec_name").value);
		str=str+"&rec_code="+encodeURIComponent(document.getElementById("hid_rec_code").value);
		
		return str;
	}
	function doSearch(){
		var str;
		if(IsAdvSearch){//高级
			str="search_type=1";
			if(document.getElementById("cb_cre_date").checked){
				if(checkDateStr()){
					str=str+"&cb_cre_date=1";
				}else{
					return;
				}
			}
			if(document.getElementById("cb_status").checked){
				str=str+"&cb_status=1";
			}
			
			if(document.getElementById("cb_rec_name").checked){
				var recName=document.getElementById("rec_name").value.trim();
				if(recName==null || recName==""){
					ShowAlert('提示框','请输入接收人姓名',200,100);
					return;
				}
				str=str+"&cb_rec_name=1";
			}
			if(document.getElementById("cb_rec_code").checked){
				var recCode=document.getElementById("rec_code").value.trim();
				if(recCode==null || recCode==""){
					ShowAlert('提示框','请输入手机号码',200,100);
					return;
				}
				str=str+"&cb_rec_code=1";
			}
		}else{//快速
			str="search_type=2";
			if(!checkDateStr()){
				return;
			}
		}
		var paraStr=createPageParaStr();
		if(paraStr!=""){
			str=str+"&"+paraStr;
		}
		window.location="/sms/SmsMyHistoryList.ihtm?"+str;
	}
	function doGo(pageIndex){
		var str=getSearchCondition();
		str=str+"&current_page="+pageIndex;
		window.location="/sms/SmsMyHistoryList.ihtm?"+str;
	}
	function getSearchCondition(){
		var searchType="${searchType}";
		var str="search_type="+searchType;
		if(searchType=="1"){//高级
			<c:if test="${cbCreDate=='1'}">str=str+"&cb_cre_date=1";</c:if>
			<c:if test="${cbStatus=='1'}">str=str+"&cb_status=1";</c:if>
			<c:if test="${cbRecName=='1'}">str=str+"&cb_rec_name=1";</c:if>
			<c:if test="${cbRecCode=='1'}">str=str+"&cb_rec_code=1";</c:if>
		}else{//快速
			
		}
		var paraStr=createProgramParaStr();
		if(paraStr!=""){
			str=str+"&"+paraStr;
		}
		return str;
	}
	function doJump(pageIndex){
		if(window.event.keyCode==13){
			doGo(pageIndex);
		}
	}
	function DoubleClick(it){
		
	}
	
	function doCancel(){
		window.close();
	}
	function doInit(){
		Window_Onload();
	}
	function checkInput(){
		if(window.event.keyCode==13){
			doSearch();
		}
	}
	function doAutoCheck(objId){
		document.getElementById(objId).checked=true;
	}
	function setDate(type){
		var d=new Date();
		var startStr="";
		var endStr="";
		if(type=="CURRENT_MONTH"){
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-01";
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="PREVIEW_MONTH"){
			d=new Date(d.getFullYear(),d.getMonth(),1);
			d.setDate(d.getDate()-1);
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-1";
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="TODAY"){
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}else if(type=="YESTERDAY"){
			d.setDate(d.getDate()-1);
			startStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
			endStr=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
		}
		document.getElementById("start_date").value=startStr;
		document.getElementById("end_date").value=endStr;
		doAutoCheck("cb_cre_date");
	}
</script>
</head>
<body>
<div class="Wrap"><!-- 页面主框架 -->
    
	<div id="ListContainer" class="Container"><!-- 主体容器 -->
	    
	    <!-- 标题栏 -->
	    <div class="Heading BillIcon">
	        <div class="HeadingContent">
	            <h1>我的发送记录</h1>
	            <span class="Note">查询自己的短信发送记录</span>
	        </div>
	    </div>
	
		<!-- 主内容 -->
		<div class="Content">
	        <!-- 筛选控件栏 -->
	        <div class="FilterBar ClearFix">
	            <div class="SearchIcon"></div>
	            <span class="fl">
	            	<table class="MoreOption" cellpadding="0" cellspacing="0">
	            		<th class="c1" width="90px">
	            			<input type="checkbox" name="cb_cre_date" id="cb_cre_date" <c:if test="${cbCreDate=='1' || searchType=='2'}">checked="true"</c:if> style="visibility:hidden;" />
	            			发送日期
	            		</th>
	            		<td width="360px">
	            			<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cre_date');" id="start_date" name="start_date" value="<c:out value="${startDate}" />">
							<input type="hidden" id="hid_start_date" value="<c:out value="${startDate}" />">
							<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('start_date'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_cre_date\')');">
							至
							<input type="text" class="TextBox Datetime" maxlength="15" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_cre_date');" id="end_date" name="end_date" value="<c:out value="${endDate}" />">
							<input type="hidden" id="hid_end_date" value="<c:out value="${endDate}" />">
							<img src="/images/calendar.gif" class="imgIconButton" onClick="displayCalendar(document.getElementById('end_date'),'yyyy-mm-dd',this,false,'doAutoCheck(\'cb_cre_date\')');">
				            <a href="javascript:setDate('CURRENT_MONTH');">本月</a>
							<a href="javascript:setDate('TODAY');">今天</a>
							<a href="javascript:setDate('YESTERDAY');">昨天</a>
							<a href="javascript:setDate('PREVIEW_MONTH');">上月</a>
	            		</td>
	            	</table>
	            </span>
	            <span class="fr">
	            	<a href="javascript:;" id="lnkMoreOption">更多查询选项</a>
		  			<input type="button" value=" 查 询" onClick="doSearch();" id="sSearchButton" name="sSearchButton" class="buttom search-but">
	            </span>
				<div id="dvMoreOptionBox" class="MoreOptionBox" style="display:none;">
					<table class="MoreOption" cellpadding="0" cellspacing="0">
						<tr>
							<th class="c1" width="90px">
			        			<input type="checkbox" name="cb_status" id="cb_status" <c:if test="${cbStatus=='1'}">checked="true"</c:if>>
			        			发送状态
			        		</th>
			        		<td class="c1" width="260px">
			        			<input type="radio" name="statusk" id="status1" onClick="doAutoCheck('cb_status');" <c:if test="${status==null || status=='' || status=='S'}">checked="true"</c:if> >成功
								<input type="radio" name="statusk" id="status2" onClick="doAutoCheck('cb_status');" <c:if test="${status=='F'}">checked="true"</c:if> >失败
								<input type="radio" name="statusk" id="status3" onClick="doAutoCheck('cb_status');" <c:if test="${status=='A'}">checked="true"</c:if> >全部
			    			</td>
			    		</tr>
			    		<tr>
							<th class="c1">
			        			<input type="checkbox" name="cb_rec_name" id="cb_rec_name" <c:if test="${cbRecName=='1'}">checked="true"</c:if>>
			        			接收人姓名
			        		</th>
			        		<td class="c1">
			        			<input type="text" class="TextBox" maxlength="15" name="rec_name" id="rec_name" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_rec_name');" value="<c:out value="${recName}" />" >
								<input type="hidden" id="hid_rec_name" value="<c:out value="${recName}" />">
			    			</td>
			    		</tr>
			    		<tr>
							<th class="c1">
			        			<input type="checkbox" name="cb_rec_code" id="cb_rec_code" <c:if test="${cbRecCode=='1'}">checked="true"</c:if>>
			        			手机号码
			        		</th>
			        		<td class="c1">
			        			<input type="text" class="TextBox" maxlength="15" name="rec_code" id="rec_code" onKeyUp="checkInput();" onFocus="doAutoCheck('cb_rec_code');" value="<c:out value="${recCode}" />" >
								<input type="hidden" id="hid_rec_code" value="<c:out value="${recCode}" />">
			    			</td>
			    		</tr>
			    	</table>
			    	
					<div class="OptionOrderBy">
	                    <span class="fr"><a href="javascript:;" id="lnkHiddenOption">隐藏查询选项</a></span>
	                </div>
				</div>
			</div>
			
			<!-- 提示信息显示栏 -->
	        <div class="MsgBar">
	            <%@include file="../inc/AlertMsg.jsp"%>
	        </div>
	        
	        <!-- 上栏 分页、操作等 -->
	        <div class="TopToolBar">
	            <table class="ListNoteInfo" cellpadding="0" cellspacing="0">
	            	<tr>
	                	<td>发送成功：${sCount} 发送失败：${fCount}</td>
	            	</tr>
	            </table>
			</div>

		    <div class="table-list">
		        <table width="100%">
		          	<tr>
					  	<th width="10%">姓名</td>
						<th width="12%">手机号码</td>
						<th width="20%">内容</td>
						<th width="14%">发送时间</td>
						<th width="14%">处理时间</td>
						<th width="14%">定时发送</td>
						<th width="8%">拆分数量</td>
						<th width="4%">结果</td>
						<th width="4%">代码</td>
		          	</tr>
					<c:forEach var="item" items="${qr.list}" varStatus="i">
					<c:if test="${(i.index mod 2)==0}"><c:set var="trClass" value="query_list_data_tr1" /></c:if>
					<c:if test="${(i.index mod 2)!=0}"><c:set var="trClass" value="query_list_data_tr2" /></c:if>
					<c:set var="defaultFontColor" value="#000000" />
					<c:if test="${item.status=='F'}"><c:set var="defaultFontColor" value="#ff0000" /></c:if>
					<tr class="${trClass}" style="color:${defaultFontColor}" defaultFontColor="${defaultFontColor}" index="${i.index+1}" style='cursor:pointer;' ondblclick='javascript:DoubleClick(this)' onClick='javascript:ClickCheck(this)' onmouseout='javascript:mouseout(this)' onmouseover='javascript:mouseover(this)'>
						<td >
							${item.receiverName}
							<input type="radio" name='query_checkbox' value="${item.id}" style="display:none">
						</td>
						<td>${item.receiverCode}</td>
						<td><c:out value="${item.content}" /></td>
						<td><fmt:formatDate value="${item.createTime}" pattern="yyyy-MM-dd HH:mm"/></td>
						<td><fmt:formatDate value="${item.sendTime}" pattern="yyyy-MM-dd HH:mm"/></td>
						<td>
							<c:if test="${item.planTime!=null}">
							<fmt:formatDate value="${item.planTime}" pattern="yyyy-MM-dd HH:mm"/>
							</c:if>
						</td>
						<td>${item.smsNum}</td>
						<td>
							<c:if test="${item.status=='S'}">成功</c:if>
							<c:if test="${item.status!='S'}">失败</c:if>
						</td>
						<td><c:if test="${item.status!='S'}">${item.mark}</c:if></td>
					</tr>
					</c:forEach>
				</table>
			</div>
			
			<!-- 底栏 分页、操作等 -->
	        <div class="BottomToolBar ClearFix">
			    <%@include file="../inc/Pages.jsp"%>
	        </div>
			
		</div>
	</div>
</div>
</body>
</html>
<script type="text/javascript">
	function ChangeWindowSize( container, maxWidth ){
	    setTimeout( function(){
	        var w1 = document.documentElement.clientWidth-40;
	        if( w1>maxWidth ) w1 = maxWidth;
	        else if( w1<870 ) w1 = 860;
	        container.style.width = w1+'px';
	    }, 300 );
	}
	var IsAdvSearch = false;
	(function(){
		doInit();
	    var ListContainer = document.getElementById('ListContainer');
	    ChangeWindowSize( ListContainer, 2020 );    // 超过 1280 的最大 1260 ，不全部铺满
	
	    var lnkMoreOption   = document.getElementById('lnkMoreOption');
	    var lnkHiddenOption = document.getElementById('lnkHiddenOption');
	    lnkMoreOption.onclick = function(){
	    	IsAdvSearch = true;
	        document.getElementById('dvMoreOptionBox').style.display = 'block';
	        document.getElementById('cb_cre_date').style.visibility = 'visible';
	        this.style.visibility = 'hidden';
	    };
	    lnkHiddenOption.onclick = function(){
	    	IsAdvSearch = false;
	        document.getElementById('dvMoreOptionBox').style.display = 'none';
	        document.getElementById('cb_cre_date').style.visibility = 'hidden';
	        lnkMoreOption.style.visibility = 'visible';
	    };
	})();
</script>
